<template>
  <div class="top">
    <div class="content">
      <div class="left" @click="toHome">
        <img src="../../assets/images/logo.png" />
        <p>尚医通 预约挂号统一平台</p>
      </div>
      <div class="right">
        <div class="help">帮助中心</div>
        <div
          v-if="!userStore.userInfo.name"
          class="login"
          @click="userStore.checkLogin"
        >
          登录/注册
        </div>
        <el-dropdown v-else>
          <span class="el-dropdown-link">
            {{ userStore.userInfo.name }}
            <el-icon class="el-icon--right">
              <arrow-down />
            </el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item @click="to('certification')"
                >实名认证</el-dropdown-item
              >
              <el-dropdown-item @click="to('order')">挂号订单</el-dropdown-item>
              <el-dropdown-item @click="to('patient')"
                >就诊人管理</el-dropdown-item
              >
              <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>
<script lang="ts" name="HospitalTop" setup>
import router from "@/router";
import useUserStore from "@/store/modules/user.ts";
import path from "path";

let userStore = useUserStore();
const logout = () => {
  userStore.logout();
};

// 去首页
function toHome() {
  router.push("/");
}
const to = (path: string) => {
  router.push({
    path: "/user/" + path,
  });
};
</script>
<style lang="scss" scoped>
.top {
  position: fixed;
  z-index: 999;
  width: 100%;
  height: 70px;
  background-color: #fff;
  display: flex;
  justify-content: center;
}

.content {
  width: 1200px;
  height: 70px;
  background-color: white;
  display: flex;
  justify-content: space-between;

  .left {
    display: flex;
    justify-content: center;
    align-items: center;

    img {
      width: 50px;
      height: 50px;
      margin-right: 10px;
    }

    p {
      font-size: 20px;
      color: #55a6fe;
    }
  }

  .right {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    color: #ccc;

    .help {
      margin-right: 10px;
    }
  }
}
</style>
